import React, { createContext } from 'react';

export const Context = createContext();

export const initialState = {
  name: '小月',
  age: 18,
};

export const reducer = (state, action) => {
  switch (action.type) {
    case 'CHANGENAME':
      return {
        ...state,
        name: Math.random(),
        age: state.age + 1,
      };
    default:
      return initialState;
  }
};
